﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using PTools.SharePointEntity.Attributes;

namespace PTools.SharePointEntity.CommonEntities
{
    /// <summary>
    /// Represents a link 
    /// </summary>
    [ListAttribute("Links")]
    public class Link : EntityBase
    {
        #region Properties
        /// <summary>
        /// The Notes of the Link
        /// </summary>
        [FieldAttribute("Comments")]
        public string Notes { get; set; }

        private SPFieldUrlValue _url;

        /// <summary>
        /// The URL of the Link
        /// </summary>
        [FieldAttribute("URL")]
        public SPFieldUrlValue URL {
            get
            {
                if (_url == null)
                    _url = new SPFieldUrlValue();
                return _url;
            }
            set
            {
                _url = value;
            }
        }
      
        #endregion

        private SPWeb _web;
        #region Constructor
        /// <summary>
        /// Represents a link
        /// </summary>
        /// <param name="web">The SPWeb object where the link is located</param>
        public Link(SPWeb web)
        {
            _web = web;
        }
        #endregion

        #region Must Implement
        /// <summary>
        /// Returns the SPWeb object where the link is located
        /// </summary>
        /// <returns></returns>
        public override Microsoft.SharePoint.SPWeb GetWeb()
        {
            return _web;
        }
        #endregion
    }
}
